class Edge:

    def __init__(self, vertex, time):
        self.vertex = vertex
        self.time = time

    def __str__(self):
        return "Edge: Vertex %s at %s \n" % (self.vertex, self.time)

    def __repr__(self):
        return self.__str__()

    def get_identify(self):
        min_id = str(min(self.vertex))
        max_id = str(max(self.vertex))
        return min_id + max_id


class Vertex:

    def __init__(self, vertex):
        self.vertex = vertex
        self.degree = 0
        self.value = 0
        self.sketch = None
        self.inverse_sampling = []
        self.cn_vertex = []

    def __lt__(self, other):
        return self.value < other.value

    def __str__(self):
        return "Vertex: %s " % (self.vertex)

    def add_degree(self):
        self.degree += 1
        degree_value = round(1 / self.degree, 6)
        # vertex_value = 0
        vertex_value = round(hash(str(self.vertex))/1e25, 10)
        self.value = degree_value+vertex_value

    def sampled_by(self, vertex):
        self.inverse_sampling.append(vertex)

    def pop_sampled_by(self, vertex):
        self.inverse_sampling.remove(vertex)

    def add_cn(self, vertex):
        contained = True
        if vertex.vertex not in self.cn_vertex:
            self.cn_vertex.append(vertex)
            contained = False
        return contained
